package nav

/*
#include<stdint.h>
#include<stdbool.h>
extern int nav_fastlz_compress(void * input,int length,void * output);
extern int nav_fastlz_compress_level(int level,void * input,int length,void * output);
extern int nav_fastlz_decompress(void * input,int length,void * output,int maxout);

*/
import "C"
import "unsafe"
import "gitee.com/hasika/cgo"

var _ unsafe.Pointer
var _ cgo.NotUsed

/*
Compress a block of data in the input buffer and returns the size of
compressed block. The size of input buffer is specified by length. The
minimum input buffer size is 16.
The output buffer must be at least 5% larger than the input buffer
and can not be smaller than 66 bytes.
If the input is not compressible, the return value might be larger than
length (input buffer size).
The input buffer and the output buffer can not overlap.

int fastlz_compress(void const * input, int length, void * output)
*/
func Fastlz_compress(input uintptr, length int32, output uintptr) int32 {
	var wrap_arg_input unsafe.Pointer
	var wrap_arg_length C.int
	var wrap_arg_output unsafe.Pointer
	wrap_arg_input = (unsafe.Pointer)(input)
	wrap_arg_length = (C.int)(length)
	wrap_arg_output = (unsafe.Pointer)(output)
	wrap_out := C.nav_fastlz_compress(wrap_arg_input, wrap_arg_length, wrap_arg_output)
	go_out := int32(wrap_out)
	return go_out
}

/*
Compress a block of data in the input buffer and returns the size of
compressed block. The size of input buffer is specified by length. The
minimum input buffer size is 16.
The output buffer must be at least 5% larger than the input buffer
and can not be smaller than 66 bytes.
If the input is not compressible, the return value might be larger than
length (input buffer size).
The input buffer and the output buffer can not overlap.
Compression level can be specified in parameter level. At the moment,
only level 1 and level 2 are supported.
Level 1 is the fastest compression and generally useful for short data.
Level 2 is slightly slower but it gives better compression ratio.
Note that the compressed data, regardless of the level, can always be
decompressed using the function fastlz_decompress above.

int fastlz_compress_level(int level, void const * input, int length, void * output)
*/
func Fastlz_compress_level(level int32, input uintptr, length int32, output uintptr) int32 {
	var wrap_arg_level C.int
	var wrap_arg_input unsafe.Pointer
	var wrap_arg_length C.int
	var wrap_arg_output unsafe.Pointer
	wrap_arg_level = (C.int)(level)
	wrap_arg_input = (unsafe.Pointer)(input)
	wrap_arg_length = (C.int)(length)
	wrap_arg_output = (unsafe.Pointer)(output)
	wrap_out := C.nav_fastlz_compress_level(wrap_arg_level, wrap_arg_input, wrap_arg_length, wrap_arg_output)
	go_out := int32(wrap_out)
	return go_out
}

/*
Decompress a block of compressed data and returns the size of the
decompressed block. If error occurs, e.g. the compressed data is
corrupted or the output buffer is not large enough, then 0 (zero)
will be returned instead.
The input buffer and the output buffer can not overlap.
Decompression is memory safe and guaranteed not to write the output buffer
more than what is specified in maxout.

int fastlz_decompress(void const * input, int length, void * output, int maxout)
*/
func Fastlz_decompress(input uintptr, length int32, output uintptr, maxout int32) int32 {
	var wrap_arg_input unsafe.Pointer
	var wrap_arg_length C.int
	var wrap_arg_output unsafe.Pointer
	var wrap_arg_maxout C.int
	wrap_arg_input = (unsafe.Pointer)(input)
	wrap_arg_length = (C.int)(length)
	wrap_arg_output = (unsafe.Pointer)(output)
	wrap_arg_maxout = (C.int)(maxout)
	wrap_out := C.nav_fastlz_decompress(wrap_arg_input, wrap_arg_length, wrap_arg_output, wrap_arg_maxout)
	go_out := int32(wrap_out)
	return go_out
}
